// VBStringXML.cpp

#include "VBXML/VBXML.h" 
XERCES_CPP_NAMESPACE_USE


// contructor
br::com::sbVB::VBXML::VBStringXML::VBStringXML(const char* s) 
{
	// cout << "debug: contructor VBStringXML(const char* s)" << endl;
	VBXML_initialize();
	if (s == 0)
		throw VBException_XML("VBStringXML(const char* s), s==0");
	XMLCh *sxml = XMLString::transcode(s);
	unsigned len = XMLString::stringLen(sxml);
	// len = stelen(s);
	// m_data.setData(sxml,2*len); // bytes per char
	m_data.setData(sxml,2*len+2); // bytes per char (+2 for terminator char)
	XMLString::release(&sxml);
}

// constructor
br::com::sbVB::VBXML::VBStringXML::VBStringXML(const XMLCh* sxml)
{
	VBXML_initialize();
	if (sxml == 0)
		throw VBException_XML("VBStringXML(const XMLCh* sxml), sxml==0");
	unsigned len = XMLString::stringLen(sxml);
	m_data.setData(sxml,2*len+2); // bytes per char (+2 for terminator char)
}

unsigned br::com::sbVB::VBXML::VBStringXML::strLen() const
{
	return (m_data.getSize()/2) - 1; // -1 of the terminator string
}


const XMLCh *br::com::sbVB::VBXML::VBStringXML::c_xmlStr() const
{
	return (const XMLCh*)m_data.getDataPointer();
}

const char *br::com::sbVB::VBXML::VBStringXML::c_str() const
{
	char *s = XMLString::transcode(c_xmlStr());
	br::com::sbVB::VBLib::VBString ret = s;
	XMLString::release(&s);
	return ret;
}

::br::com::sbVB::VBLib::VBString br::com::sbVB::VBXML::VBStringXML::getStringInHex() const
{
	return m_data.getStringInHex();
}
